// Room 1: Opening screen

#include "defines.txt"
#define glint_location v253
#define glint_prev_location v254
#define glint_timer v255
#define glint_completed f255
#define glint_obj o1

if (new_room) {
  load.pic(room_no);
  draw.pic(room_no);
  discard.pic(room_no);
  status.line.off();
  prevent.input();
  program.control();
  set(disable_game_functions);
  cycle_delay = speed_fast;

  set(script_buffer_blocked);       // Block writes to the script buffer to prevent overflow

  load.view(10);
  load.view(11);
  add.to.pic(10, 0, 0, 58, 77, 15, 4);    // A
  add.to.pic(10, 0, 1, 76, 77, 15, 4);    // G
  add.to.pic(10, 0, 2, 94, 77, 15, 4);    // I
  add.to.pic(10, 0, 3, 25, 139, 15, 4);   // Q
  add.to.pic(10, 0, 4, 43, 136, 15, 4);   // U
  add.to.pic(10, 0, 5, 61, 136, 15, 4);   // E
  add.to.pic(10, 0, 6, 79, 136, 15, 4);   // S
  add.to.pic(10, 0, 7, 96, 136, 15, 4);   // T
  add.to.pic(10, 0, 8, 122, 136, 15, 4);  // 1
  add.to.pic(11, 0, 0, 23, 156, 15, 4);   // Subtitle
  discard.view(10);

  reset(script_buffer_blocked);     // Enable the script buffer

  load.view(12);
  animate.obj(glint_obj);
  set.view(glint_obj, 12);
  set.priority(glint_obj, 15);
  ignore.objs(glint_obj);
  ignore.horizon(glint_obj);
  load.sound(opening_music);
  sound(opening_music, f254);
  show.pic();
  display(23, 5, "Copyright 1997, 2004 Juha Terho");

  glint_timer = 0;
  reset(glint_completed);
}

glint_timer++;

if (glint_timer == 8) {
  glint_prev_location = glint_location;
ConsideredHarmful:
  random(0, 18, glint_location);
  if (glint_location == glint_prev_location) { goto(ConsideredHarmful); }
  if (glint_location == 0) { position(glint_obj, 21, 88); }
  if (glint_location == 1) { position(glint_obj, 29, 136); }
  if (glint_location == 2) { position(glint_obj, 38, 87); }
  if (glint_location == 3) { position(glint_obj, 47, 135); }
  if (glint_location == 4) { position(glint_obj, 48, 87); }
  if (glint_location == 5) { position(glint_obj, 53, 29); }
  if (glint_location == 6) { position(glint_obj, 56, 87); }
  if (glint_location == 7) { position(glint_obj, 63, 54); }
  if (glint_location == 8) { position(glint_obj, 63, 82); }
  if (glint_location == 9) { position(glint_obj, 72, 30); }
  if (glint_location == 10) { position(glint_obj, 74, 125); }
  if (glint_location == 11) { position(glint_obj, 75, 89); }
  if (glint_location == 12) { position(glint_obj, 79, 54); }
  if (glint_location == 13) { position(glint_obj, 80, 76); }
  if (glint_location == 14) { position(glint_obj, 83, 135); }
  if (glint_location == 15) { position(glint_obj, 89, 28); }
  if (glint_location == 16) { position(glint_obj, 91, 87); }
  if (glint_location == 17) { position(glint_obj, 117, 87); }
  if (glint_location == 18) { position(glint_obj, 117, 136); }
  set.cel(glint_obj, 0);
  end.of.loop(glint_obj, glint_completed);
  draw(glint_obj);
  glint_timer = 0;
}

if (glint_completed) {
  erase(glint_obj);
  reset(glint_completed);
}

if (have.key()) {
  set(menu_enabled);
  clear.lines(22, 24, 0);
  stop.motion(ego);
  reset(disable_game_functions);
  cycle_delay = speed_normal;
  new.room(beach);
}

return();